<?php
namespace Hive\Ressource;
/**
 * Source Object.
 *
 * It represant an external data source for the contact
 * Contact can be linked to social network data, to do so we need the id of the contact
 * in the external social network.
 * Those ids are stored as Source reference
 * filled correctly.
 *
 * @author Xavier VILAIN
 * @package common
 * @subpackage ressource
 *
 * @property string	$ressource_id	Ressource Id
 * @property string	$type			Source Type (1 for Viadeo, 2 for LinkedId...)
 * @property string	$reference		Unique Id in the source environment
 */
class Source extends \Fox\Object {

	/**
	 * Link To Source Type
	 * @var string
	 */
	const LINK_TYPE = 'type';

	/**
	 * Link To Ressource
	 * @var string
	 */
	const LINK_RESSOURCE = 'ressource';
	
	/**
	 * (non-PHPdoc)
	 * @see Fox.Object::afterUpdate()
	 */
	protected function beforeUpdate($changed) {
		// Try to recover User Source Id
		
	}
}
\Fox\Dao::infos(
	Source::className(),
	new \Fox\Object\Info('ressource_sources', \Fox\Databases::DB_APP)
);

\Fox\Object\Links::add(\Fox\Dao::link(Source::className(),Source::LINK_TYPE)
	->to(Source\Type::className(), Source\Type::LINK_SOURCES)
	->on('type')
	->oneToOne()
	->cache(new \Fox\Dao\MemoryCacheZone(\Fox\Dao\MemoryCacheZone::PERIOD_FOREVER,Source::cacheDirectory()))
	->linkOnly()
);